\documentclass[a4wide, 11pt]{article}
\usepackage{a4, fullpage}
\setlength{\parskip}{0.3cm}
\setlength{\parindent}{0cm}

% This is the preamble section where you can include extra packages etc.

\begin{document}


\title{MAlice Language Specification}

\author{Tim Kimber \and Paul Kelly \and Nicolas Loriant}

\date{\today}         % inserts today's date

\maketitle            % generates the title from the data above

\section{Introduction}

This is an \emph{introductory comment}.
\LaTeX\ can typeset some very complex documents, but it is also
\textbf{quite easy to get started}.
Try playing around with this file and see. 
Don't worry that this page looks very spaced out,
\LaTeX\ arranges the page for you (much less work to do than in Word!)
so if there was more content it would close up the gaps.

To start a new paragraph just leave a blank line.
If you do not like numbered sections, use the \texttt{section*\{...\}}
environment instead.

\section{BNF Grammar} 

\begin{verbatim}
    The verbatim environment outputs the source without changing
    it in any way. 
          This
              includes line breaks
       and indentation. 
    It is useful to reproduce code snippets.
\end{verbatim}

To include maths formulas in text put them between \$ symbols like this
$f(x) = x \times 5$.
Or to display a formula on a line on its own you do this:
\[
    g(y) = y^2
\]


\begin{verbatim}

literal ::= "bool"
            | "int"
            | "float"
            | "char"
            | "string"

primary_expr ::= id
                 | decl
                 | literal

decl ::= id "was" "a" type_id

unary_expr ::= primary_expr
               | '(' expr ')'
               | '-' cast_expr
               | '+' cast_expr
               | '~' cast_expr

cast_expr ::= unary_expr
              | '(' type_id ')' cast_expr

multiplicative_expr ::= cast_expr
                        | multiplicative_expr '*' unary_expr
                        | multiplicative_expr '/' unary_expr
                        | multiplicative_expr '%' unary_expr

\\TO BE FORMATTED

additive_expr
: multiplicative_expr
| additive_expr '+' multiplicative_expr
| additive_expr '-' multiplicative_expr
;

shift_expr
: additive_expr
| shift_expr "<<" additive_expr
| shift_expr ">>" additive_expr
;

relational_expr
: shift_expr
| relational_expr "<"  shift_expr
| relational_expr ">"  shift_expr
| relational_expr "<=" shift_expr
| relational_expr ">=" shift_expr
;

equality_expr
: relational_expr
| equality_expr "==" relational_expr
| equality_expr "!=" relational_expr
;

and_expr
: equality_expr
| and_expr "&" equality_expr
;

xor_expr
: and_expr
| xor_expr "^" and_expr
;

or_expr
: and_expr
| or_expr "|" xor_expr
;

assignment_expr
: id "became" or_expr
;

expr
:	decl
| expr "," assignment_expr 
| expr "and" assignment_expr
| expr "but" assignment_expr
;

stmt_seq
: stmt
| stmt_seq stmt
;

stmt
: expr stmt_term "newline"
| return_stmt
;

stmt_term
: "."
| ","
;

\end{verbatim}

\section{Semantics}

Here is a numbered list.

\begin{enumerate}

    \item
    This is item 1.
    
    \item
    And this is item 2.
    
\end{enumerate}

And here is a bulleted list.

\begin{itemize}

    \item
    The parts of the list are called items here too.
    
\end{itemize}

Finally for this document, if you want to include a reference
then you put it into a \texttt{thebibliography\{...\}}
environment (see below in source file) and then 
cite it like this \cite{lamport94}
(you will need to run \texttt{latex} twice to get it to process the citation),
or you can use BibTex but that is probably overkill for now.

\begin{thebibliography}{9}

\bibitem{lamport94}
  Leslie Lamport,
  \emph{\LaTeX: A Document Preparation System}.
  Addison Wesley, Massachusetts,
  2nd Edition,
  1994.

\end{thebibliography}


\end{document}
